package com.hzncc.flowable_diboot.job;

import com.diboot.scheduler.annotation.CollectThisJob;
import com.hzncc.flowable_diboot.service.impl.CustomerServiceImpl;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.quartz.QuartzJobBean;

@DisallowConcurrentExecution
@CollectThisJob(
        name = "进入公海检测",
        cron = "0 0 2 * * ? "
)
public class CustomOperJob extends QuartzJobBean implements ApplicationContextAware {

    private ApplicationContext applicationContext;

    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        CustomerServiceImpl service = applicationContext.getBean(CustomerServiceImpl.class);
        try {
            service.checkFollowTime();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }


}
